<template>
  <div style="width: 100%; height: 100%">
    <div class="bg">
      <div class="box1"></div>
      <div class="p">
        <p>双线质量管控体</p>
      </div>
      <div class="p1">
        <p>力求每个产品、每个细节都尽善尽美</p>
      </div>
      <div class="p2">
        <p>够专业 才放心</p>
      </div>
      <div class="box2"></div>
      <div class="buttom">
        <p>All Rights Reserved ©2021 版权所有 |粤ICP备18069755号</p>
      </div>
      <div class="bigbox">
        <div class="inp1">
          <p>欢迎使用</p>
        </div>
        <div class="inp2" @click="submitForm">
          <p>系统登陆</p>
        </div>
        <el-form :model="ruleForm" :hide-required-asterisk="true" :rules="rules" ref="ruleForm" label-width="60px" class="inputBox">
          <div class="inputDiv">
          <el-form-item label="用户名" prop="userName">
            <el-input autosize v-model="ruleForm.userName">
              <img slot="prefix" class="inputIcon" src="../assets/loginimage/user.png" />
            </el-input>
          </el-form-item>
        </div>
        <div class="inputDiv">
          <el-form-item label="密  码" prop="passWord">
            <el-input autosize type="password" v-model="ruleForm.passWord">
              <img slot="prefix" class="inputIcon" src="../assets/loginimage/code.png" />
            </el-input>
          </el-form-item>
        </div>
        </el-form>
        <div class="login" @click="submitForm">
          <p>登陆</p>
        </div>
      </div>
      <div class="order1">
        <p>ORDER聚造</p>
      </div>
      <div class="order2">
        <p>ORDER聚造</p>
      </div>
    </div>
  </div>
</template>

<script>
import md5 from 'js-md5'


export default {
  name: "login",
  components: {
    //HelloWorld
    // 组件的引用
  },
  data() {
    return {
      ruleForm:{
        userName:'',
        passWord:''
      },
      rules: {
        userName: [
            { required: true, message: '请输入用户名', trigger: 'blur' },
        ],
        passWord: [
            { required: true, message: '请输入密码', trigger: 'blur' },
        ],        
      }
    }
  },
  methods: {
    submitForm() {
      // console.log('this.$refs',this.$refs)
      this.$refs.ruleForm.validate((valid) => {
         if (valid) {
          this.$http({
            url:'/login',
            method:'POST',
            data:{
              userName:this.ruleForm.userName,
              passWord:md5(this.ruleForm.passWord),
              platform:'Web'
             }
          }).then(res => {
            if(!res.errorMsg){
              localStorage.setItem('token',res.token)
              localStorage.setItem('user',JSON.stringify(res))
              this.$router.push('/index')
            }
          })
        } 
      });     
    },
  },
  created() {},
  mounted() {},
};
</script>


<style scoped>

.bg {
  background-image: url("../assets/loginimage/bg.png");
  width: 100%;
  height: 100%;
  border-radius: 0px 0px 0px 0px;
  background-size: cover;
  display: flex;
}

.box1 {
  width: 118px;
  height: 162px;
  background: #e1f2f9;
  border-radius: 0px 0px 0px 0px;
  opacity: 0.3;
  margin-top: 202px;
  margin-left: 85px;
  position: absolute;
}

.p {
  width: 126px;
  height: 23px;
  font-size: 18px;
  font-family: MicrosoftYaHeiUI-Bold-, MicrosoftYaHeiUI-Bold;
  color: #ffffff;
  line-height: 0px;
  margin-top: 260px;
  margin-left: 81px;
  position: absolute;
}

.p1 {
  width: 256px;
  height: 20px;
  font-size: 16px;
  font-family: MicrosoftYaHeiUI-Bold-, MicrosoftYaHeiUI-Bold;
  color: #ffffff;
  margin-top: 326px;
  margin-left: 56px;
  position: absolute;
}

.p2 {
  width: 194px;
  height: 35px;
  font-size: 28px;
  font-family: MicrosoftYaHeiUI-Bold-, MicrosoftYaHeiUI-Bold;
  font-weight: normal;
  color: #6bb9da;
  margin-top: 335px;
  margin-left: 134px;
  position: absolute;
}

.box2 {
  width: 135px;
  height: 164px;
  background: #e1f2f9;
  border-radius: 0px 0px 0px 0px;
  opacity: 0.3;
  margin-top: 364px;
  margin-left: 157px;
  position: absolute;
}

.buttom {
  width: 406px;
  height: 16px;
  font-size: 14px;
  font-family: MicrosoftYaHeiUI-Bold-, MicrosoftYaHeiUI-Bold;
  color: #565656;
  margin-left: 446px;
  margin-top: 680px;
  position: absolute;
  font-weight: bold;
}

.bigbox {
  width: 359px;
  height: 359px;
  background: #efeff0;
  border-radius: 20px 20px 20px 20px;
  opacity: 0.9;
  margin-top: 223px;
  margin-left: 60%;
}

.inp1 {
  width: 52px;
  height: 16px;
  font-size: 13px;
  font-family: MicrosoftYaHeiUI-, MicrosoftYaHeiUI;
  color: #96a3b0;
  margin-top: 23px;
  margin-left: 32px;
}

.inp2 {
  width: 333px;
  height: 60px;
  font-size: 27px;
  font-family: MicrosoftYaHeiUI-Bold-, MicrosoftYaHeiUI-Bold;
  color: #4e4e4e;
  margin-left: 32px;
}
 .inputBox {
  
    margin-left: 40px;
  }
 .inputDiv{
    margin-right: 36px;
    height: 50px;
    margin-top: 11px;
  }

.inputIcon{
    width: 18px;
    height: 18px;
    margin-top: 12px;
    margin-left: 4px;
  }

.img {
  width: 12px;
  height: 14px;
}

.put {
  width: 200px;
  height: 37px;
  background: #ffffff;
  border-radius: 5px 5px 5px 5px;
  border: 1px solid #f3f5f8;
  margin-left: 20px;
}

.login {
  width: 302px;
  height: 38px;
  background: #409eff;
  border-radius: 19px 19px 19px 19px;
  opacity: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 50px;
  margin-left: 32px;
  font-size: 16px;
  font-family: MicrosoftYaHeiUI-, MicrosoftYaHeiUI;
  font-weight: normal;
  color: #f4f4f5;
}

.order1 {
  width: 220px;
  height: 46px;
  font-size: 36px;
  font-family: MicrosoftYaHeiUI-Bold-, MicrosoftYaHeiUI-Bold;
  font-weight: normal;
  color: #d7e8fa;
  position: absolute;
  margin-top: 630px;
  margin-left: 1250px;
  font-weight: bold;
}

.order2 {
  width: 150px;
  height: 25px;
  font-size: 25px;
  font-family: MicrosoftYaHeiUI-Bold-, MicrosoftYaHeiUI-Bold;
  font-weight: normal;
  color: #409eff;
  margin-top: 665px;
  margin-left: 1255px;
  position: absolute;
  font-weight: bold;
}
@media screen and (max-width: 1440px) {
  .bigbox {
    transform: translate(50px, -55%) scale(0.8);
  }
}
</style>
